package com.zjsru.plan2025.oneday;

/**
 * 3340. 检查平衡字符串
 *
 * @Author: cookLee
 * @Date: 2025-03-15
 */
public class IsBalanced {

    public static void main(String[] args) {
        IsBalanced isBalanced = new IsBalanced();
        System.out.println(isBalanced.isBalanced("1234"));
    }

    public boolean isBalanced(String num) {
        int len = num.length();
        int oddSum = 0;
        int evenSum = 0;
        for (int i = 0; i < len; i++) {
            if (i % 2 == 0) {
                evenSum += num.charAt(i) - '0';
            } else {
                oddSum += num.charAt(i) - '0';
            }
            
        }
        return oddSum == evenSum;
    }

}
